#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "net_utils.h"
int main(int argc, char **argv) {
  net_deley_init();
  char **ips = (char **)malloc((argc - 1) * sizeof(char *));
  for (int i = 1; i < argc; i++) {
    ips[i - 1] = argv[i];
  }
  int *arr = get_net_delay(argc - 1, ips);
  if (arr) {
    for (int i = 0; i < argc - 1; i++) {
      printf("%s : %d us\n", ips[i], arr[i]);
    }
  }
  // iperf服务器地址
  char *iperf_server = "127.0.0.1";
  iperf_result_t bandwidth = iperf_measure_bandwidth(iperf_server, 20080, 5);
  printf("iperf mis %s : upload = %.2f, download = %.2f bits_per_second\n", iperf_server,
         bandwidth.bandwidth_upload, bandwidth.bandwidth_download);
  free(ips);

  return 0;
}
